/**
 * @ author: 汪孟苹
 */
define(["jquery","bbcare","comm/datatable/datatable"],function($,$bb,$datatable){
	var servers = {};
	var URL = $bb.baseUrl("followapp");
    
    /**
     * 入参
     */
    var inParams = function(args){
        var params = $bb.getPageParams();
        var data = JSON.stringify({
            data: {
                "args": JSON.stringify(args),
                "busiType":params.busiType,
                "showFlag":"1",
                "userName": $.trim($('#userName').val()),
                "phoneNo": $.trim($('#phoneNo').val()),
                "inoculationCard": $.trim($('#inoculationCard').val()),
            }
        });
        return data;
    }
    /**
     * 出参
     */
    var outParams = function(data){
        return data.rows;
    }
    /**
     * columns
     */
    var columnSendStatus = function(e){
        return e.sendStatus == "1" ? "成功" : e.sendStatus == "2" ? "失败" : "--";
    }
    var columnsData = function(){
        var columnsArr = [
            {"data":'inoculationCard'},
            {"data":'userName'},
            {"data":'birthday'},
            {"data":'phoneNo'},
            {"data":'taskName'},
            {"data":'sendTime'},
            {"data":columnSendStatus},
            {"data":'smsType'}
        ];
        return columnsArr;
    }
    /**
     * 初始化完成之后的回调函数
     */
    var initComplete = function(setting,json){
        var id = $(".layout-bottom table").attr("id");
        $("#" + id).prev("div.row").remove();
        $("#serchBtn").bind("click",function(){
            $datatable.table.api().ajax.reload();  // 出发dt的重新加载数据的方法
            var args = $datatable.table.api().ajax.params();   //获取dt请求参数
        });
    }
    /**
     * 获取datatable里的options
     */
    servers.getOptions = function(){
        var sessionId = $bb.getSessionStorage("sessionId");
        var options = {
            "ajax": {
                "url": URL + "ctrl/VaccineInfo/selectUserRemaindMassage?sessionId=" + sessionId,
                "data": inParams,
                "dataSrc": outParams
            },
            "columns": columnsData(),
            "initComplete": initComplete,
        };
        return options;
    }

	return servers;
});